<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客正文</title>
    <link rel="stylesheet" href="css/conmmon.css">
    <link rel="stylesheet" href="css/blog_content.css">
    <link rel="stylesheet" href="editor.md/css/editormd.preview.min.css" />
    <link rel="shortcut icon" href="favicon.ico">
    <script src="js/jquery.min.js"></script>
    <script src="editor.md/editormd.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>

</head>

<body>
    <!-- 导航栏 -->
    <div class="nav">
        <img src="img/logo2.jpg" alt="">
        <span class="title">我的博客系统</span>
        <!-- 用来占据中间位置 -->
        <span class="spacer"></span>
        <a href="blog_list.html">主页</a>
        <a href="blog_edit.html">写博客</a>
        <a href="blog_login.html">退出</a>
    </div>
    <!-- 版心 -->
    <div class="container">
        <!-- 左侧个人信息 -->
        <div class="container-left">
            <div class="card">
                <img src="img/avatar.png" class="avtar" alt="">
                <h3></h3>
                <a href="http:www.github.com">github 地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>
        </div>
        <!-- 右侧内容详情 -->
        <div class="container-right">
            <div class="blog-content">
                <!-- 博客标题 -->
                <h3><div class="title"></div></h3>
                <!-- 博客时间 -->
                <div class="date"></div>
                <!-- 博客正文 -->
                <div class="content" id="content" style="background-color: transparent;"></div>
<!--                <div class="operating">-->
<!--                    <button onclick="window.location.href='blog_edit.html'">编辑</button>-->
<!--                    <button onclick="deleteBlog()">删除</button>-->
<!--                </div>-->
            </div>
        </div>
    </div>
    <!-- 引入 editor.md 的依赖 -->
    <link rel="stylesheet" href="editor.md/css/editormd.css" />
    <script src="js/jquery.min.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>
    <script src="js/common.js"></script>
    <script>
        $.ajax({
            type:"get",
            url:"/blog/queryBlogDetail"+location.search,
            success:function (result){
                if (result.code==200 && result.data!=null){
                    var blog = result.data;
                    $(".container-right .blog-content .title").text(blog.title);
                    $(".container-right .blog-content .date").text(blog.createTime);
                    // $(".container-right .blog-content .content").text(blog.content);
                    editormd.markdownToHTML("content", {
                        markdown: blog.content,
                    });
                    //是否显示编辑/删除按钮
                    if(blog.loginUser){
                        console.log("显示编辑/删除");
                        var html = "";
                        html += '<div class="operating">';
                        html += '<button onclick="window.location.href=\'blog_update.html'+location.search+'\'">编辑</button>';
                        html += '<button onclick="deleteBlog()">删除</button>';
                        html += '</div>';

                        $(".content").append(html);
                    }
                }
            }
        })
        //显示博客作者信息
        var userUrl = "/user/getAuthorInfo" + location.search;
        getUserInfo(userUrl);

        function deleteBlog() {
            alert("删除博客");
        }
    </script>
</body>

</html>